'''
''' Inserts a new record into the table. Start a transaction before
''' calling this function.
'''
Public Shared Sub AddRecord()
' Create an empty record.
Dim rec As New ${${Table Name}RecordClassName}
' Set the fields of the new record as follows.
rec.${Field Name} = "1"
' Set more field values here...
' Insert the new record into the database.
' Save adds the record to the database but commit
' happens when the page has completed its processing
rec.Save()
' Example shown below calls AddRecord() function on a button click.
' Note that you need to add transaction handling as shown below.
'Public Overrides Sub Button_Click(ByVal sender As Object, ByVal args As EventArgs)
' Try
' DbUtils.StartTransaction()
' OrdersRecord.AddRecord()
' DbUtils.CommitTransaction()
' Me.DataChanged = True
' Catch ex As Exception
' DbUtils.RollBackTransaction()
' Utils.MiscUtils.RegisterJScriptAlert(Me, "UNIQUE_SCRIPTKEY", ex.Message)
' Finally
' DbUtils.EndTransaction()
' End Try
'End Sub
End Sub
|